package com.yc.meeting_attendance;

import android.app.Application;
import android.os.Build;
import android.os.StrictMode;

import com.yc.meeting_attendance.utils.CrashHandler;
import com.yc.meeting_attendance.utils.RealmHelper;
import com.yc.meeting_attendance.utils.SharePreferenceUtil;
import com.yc.meeting_attendance.utils.logger.Logger;

import java.util.ArrayList;
import java.util.List;

import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * Created by PC on 2017/4/13.
 */

public class MyApp extends Application {

    private static MyApp sInstance;
    public SharePreferenceUtil sharePreferenceUtil;
    public List<String> bigenCard = new ArrayList<>();
    public List<String> endCard = new ArrayList<>();
    public List<String> meetingId = new ArrayList<>();
    public List<String> courseId = new ArrayList<>();

    private int giDestPort ;
    private String Card ;

    private CrashHandler crashHandler;
    @Override
    public void onCreate() {
        super.onCreate();
        sInstance = this;
        sharePreferenceUtil = new SharePreferenceUtil(this, "meetig");
        Realm.init(this);
        RealmConfiguration configuration = new RealmConfiguration.Builder()
                .name(RealmHelper.DB_NAME)
                .deleteRealmIfMigrationNeeded()
                .build();
        Realm.setDefaultConfiguration(configuration);

        if (BuildConfig.DEBUG) {
            Logger.init();
            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
                    .detectAll()
                    .penaltyLog()
                    .build());
            StrictMode.ThreadPolicy.Builder threadPolicyBuilder = new StrictMode.ThreadPolicy.Builder()
                    .detectAll()
                    .penaltyLog();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                threadPolicyBuilder.penaltyDeathOnNetwork();
            }
            StrictMode.setThreadPolicy(threadPolicyBuilder.build());

        }
        //发布版本 启动异常重启模式 发布时：打开，测试时：关闭 因为这可以屏蔽 Bug 都交给系统异常处理
        crashHandler = CrashHandler.getInstance();
        crashHandler.init(getApplicationContext());

    }

    public static MyApp getsInstance() {
        return sInstance;
    }

    public int getgiDestPort() {
        return this.giDestPort;
    }

    public void setgiDestPort(int c) {
        this.giDestPort = c;
    }

    public void setCard(String Card) {
        this.Card = Card;
    }

    public String getCard() {
        return Card;
    }

    public List<String> getMeetingId() {
        return meetingId;
    }

    public void setMeetingId(List<String> meetingId) {
        this.meetingId = meetingId;
    }

    public List<String> getBigenCard() {
        return bigenCard;
    }

    public void setBigenCard(List<String> bigenCard) {

        this.bigenCard = bigenCard;
    }

    public List<String> getEndCard() {
        return endCard;
    }

    public void setEndCard(List<String> endCard) {
        this.endCard = endCard;

    }

    public List<String> getCourseId() {
        return courseId;
    }

    public void setCourseId(List<String> courseId) {
        this.courseId = courseId;

    }
}
